package com.ctshk.sapp.order.train.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.rpc.order.train.req.TrainOrderRefundApprovalReq;
import com.ctshk.rpc.order.train.req.TrainOrderRefundUpdateReq;
import com.ctshk.rpc.order.train.service.ITrainOrderRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

/**
 * <p>
 * 火车退款记录 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-03-17
 */
@Api(value="订单中心-订单退款", tags="订单中心-订单退款")
@RestController
@RequestMapping("/train-order-refund")
public class TrainOrderRefundController extends BaseController {

    @DubboReference
    ITrainOrderRefundService trainOrderRefundService;


    @ApiOperation(value = "订单中心火车票退款记录-删除", notes = "订单中心火车票退款记录-删除")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "订单中心火车票退款记录-删除", operDesc = "订单中心火车票退款记录-删除")
    @GetMapping(value = "/delete/{refundId}")
    public Result delete(@PathVariable Long refundId){
        return trainOrderRefundService.delete(refundId,getCurrentUser(getRequest()).getId());
    }

    @ApiOperation(value = "审批中心 - 退款审核", notes = "审批中心 - 退款审核")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "订单中心 - 操作订单退款记录 - 操作退款", operDesc = "订单中心 - 操作订单退款记录 - 操作退款")
    @PostMapping(value = "/approval")
    public Result approval(@RequestBody TrainOrderRefundApprovalReq req){
        req.setUserId(getCurrentUser(getRequest()).getId());
        return trainOrderRefundService.approval(req);
    }
}
